home *** CD-ROM | disk | FTP | other *** search
/ Die Speccy' 97 / Die Speccy' 97.iso / amiga_system / the_aminet / comm / misc / dcdd_v2_4.lha / Do_PNET.rexx < prev    next >
OS/2 REXX Batch file  |  1995-09-05  |  13KB  |  498 lines

  1. /* 
  2.    Do_PNET.rexx                   Version 1.4                    950803.0503
  3.  
  4. 950728 - added X.OTHER gather-up area (for PGP stuff to start) 
  5.  
  6.                   NOTE:    +r = TEST i.e. no updates 
  7.                            when adding new newsgroup areas don't
  8.                            forget the *** STUFF *** at the end....
  9.  
  10. 950731 - killed DF as it does not seem to work anymore.. just hangs there..
  11. 950803 - put DF back as it works now (after I sent Nathan a message)
  12.  
  13. */
  14.  
  15. address BAUD /* must have this here */
  16. OPTIONS RESULTS
  17.  
  18. parse arg N_args
  19.  
  20. parse var N_args PW1 PW2 Xargs
  21.  
  22. /*
  23. msg '************************'
  24. msg 'Args = ' PW1 ' ' PW2 ' ' Xargs
  25. msg '************************'
  26.  
  27.   call delay(600) 
  28. */
  29.  
  30. auto = 'X'
  31. test = 'X'
  32. waitlost = ' '
  33.  
  34.  
  35. if exists('ram:PNET_TEST')~=0 then   
  36.    test = 'y'
  37.  
  38. if exists('ram:AUTO')~=0 then   
  39.    auto = 'y'
  40.  
  41. call LOGON                              /* for A and B */
  42.  
  43. /*
  44. send '"set prompt = '][> '"\r'
  45. */
  46.  
  47. /* 
  48. ** ---- below killed 950731 as it hangs up and just sits there....
  49. ** ---- below turned back on 950803. (Nathan got it fixed)
  50. */
  51.  
  52. if waitlost = 'n' then do 
  53.    call AUTO_DF                         /* for C */
  54. end
  55.  
  56. /*
  57. ** ---- above turned back on 950803. (Nathan got it fixed)
  58. ** ---- above killed 950731 as it hangs up and just sits there....
  59. */
  60.  
  61. if auto = 'y' then do
  62.    if waitlost = 'n' then 
  63.       call AUTO_SOUP                    /* for D thru X */
  64. end 
  65.  
  66. if auto = 'y' then do
  67.    if waitlost = 'n' then 
  68.       call CLEANUP
  69. end
  70.  
  71. /* below gets you out of any process that has had problems */
  72.  
  73. if waitlost ~= 'n' then do
  74.    if exists('RAM:continue')~=0 then do
  75.       address command 'delete RAM:continue'
  76.       exit
  77.    end
  78. end
  79.  
  80. return
  81.  
  82. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  83.  *                                                             *
  84.  *                   Functions / Subroutines                   *
  85.  *                                                             *
  86.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  87.  
  88. LOGON:
  89. address BAUD /* must have this here */
  90.  
  91. waitlost = ' '
  92. do forever
  93. nput='NO CARRIER,login:,Password:'
  94. wait nput
  95. NRC = RC
  96. NRESULT = RESULT
  97.    if NRC > 0 then do  /* waited 30 seconds & no nput items on serial port */
  98.       waitlost = 'y'
  99.       msg '****** LOGON - wait is LOST! ******'
  100.       Capture OFF
  101.       leave  
  102.    end
  103.  
  104. /* 
  105.  
  106. NOTE: Your Password on PNET  MUST!  be UPPER CASE or item below will fail.
  107.          The parse command is "parse upper" as the default!
  108. */
  109.  
  110.    if NRESULT = 'Password:' then do
  111.       call delay(2) 
  112.       waitlost = 'n'
  113.       send PW1                          /* B */
  114.       send '\w\w\w\w\r'
  115.    end     
  116.  
  117.    if NRESULT = 'login:' then do
  118.       call delay(2) 
  119.       send 'your.id'                    /* A */
  120.       send '\w\w\w\w\r'
  121.    end
  122.  
  123. /*
  124.    if NRESULT = '' then do
  125.       waitlost = 'y'
  126.       leave
  127.    end
  128. */
  129.  
  130.    if NRESULT = 'NO CARRIER' then do             /* if logon really gets  */
  131.       waitlost = 'y'                             /*          LOST         */
  132.       leave                                      /* this will get you OUT */
  133.    end
  134.  
  135.    if waitlost ~= ' ' then
  136.       leave
  137.  
  138. end
  139. return
  140.  
  141. AUTO_DF:                /* Get Primenet Directory List */
  142. OPTIONS RESULTS
  143. address command
  144.  
  145. address BAUD /* must have this here */ 
  146.  
  147. waitlost = ' '
  148. X_loop_count = 0
  149. DONE_ONCE = 'n'  
  150.  
  151. timeout 60      /* wait continues if no response within 1 minute */
  152.  
  153. do forever  
  154. nput='NO CARRIER,][>' 
  155.  
  156. wait nput  
  157. NRC = RC
  158. NRESULT = RESULT
  159.    if NRC > 0 then do  /* waited 1 minute & no nput items on serial port */ 
  160.       waitlost = 'y'
  161.       msg '****** AUTO_DF - wait is LOST! ******'
  162.       Capture OFF
  163.       leave  
  164.    end
  165.  
  166.    if NRESULT = 'NO CARRIER' then do
  167.       waitlost = 'y'           
  168.       leave                                    
  169.    end
  170.  
  171.    X_loop_count = X_loop_count + 1
  172.  
  173.    if NRESULT = '][>' then do                       
  174.       if X_loop_count = 1 then
  175.          send 'df'                      /* C */
  176.          send '\r' 
  177.    end       
  178.  
  179.    if NRESULT = '][>' then do                       
  180.       if X_loop_count = 2 then
  181.          waitlost = 'n'            
  182.    end       
  183.  
  184.    if waitlost ~= ' ' then
  185.       leave
  186.  
  187. end
  188. return
  189.  
  190. AUTO_SOUP:                /* doing SOUP packets of NewsGroups   */
  191. OPTIONS RESULTS           /* because these are clear text files */
  192. address command           /* when de-compressed.                */         
  193.  
  194. address BAUD /* must have this here */ 
  195.  
  196. waitlost = ' '
  197. X_loop_count = 0
  198. DONE_ONCE = 'n'  
  199.  
  200. timeout 600      /* wait continues if no connectstring within 10 minutes */
  201.  
  202. do forever  
  203. nput='NO CARRIER,][>' 
  204.  
  205. wait nput  
  206. NRC = RC
  207. NRESULT = RESULT
  208.    if NRC > 0 then do  /* waited 10 minutes & no nput items on serial port */ 
  209.       waitlost = 'y'
  210.       msg '****** AUTO_SOUP - wait is LOST! ******'
  211.       Capture OFF
  212.       leave  
  213.    end
  214.  
  215.    if NRESULT = 'NO CARRIER' then do
  216.       waitlost = 'y'           
  217.       leave                                    
  218.    end
  219.  
  220.    if NRESULT = '][>' then do                  /* this section not used */     
  221.       if X_loop_count = 0 then do              /* much with multi group */     
  222.          if exists('ram:.newsrc')~=0 then do   /* sessions.             */  
  223.             if DONE_ONCE = 'n' then do
  224.                address command 'copy RAM:.newsrc RAM:-dl/.newsrc'    
  225.                send '\w\w\w\w'
  226.                send 'rz -b -w 2048'
  227.                send '\r' 
  228.                send '\w\w'
  229.                send '\au-.newsrc'
  230.                send '\w\w'
  231.                DONE_ONCE = 'y'
  232.                if exists('RAM:-dl/.newsrc')~=0 then do  
  233.                   address command 'delete RAM:-dl/.newsrc'    
  234.                end
  235.             end
  236.          end
  237.          send '\w\w'
  238.          send '\r' 
  239.       end
  240.  
  241.       X_loop_count = X_loop_count + 1
  242.  
  243.       /* get the MAIL */
  244.  
  245.       if X_loop_count = 1 then do                   
  246.          send '\w\w'
  247. /*       send 'uqwk -n +L +m +r'             +r = TEST i.e. no updates    */
  248.          send 'uqwk -n +L +m'              /* D */  
  249.          send '\r'
  250.       end
  251.  
  252.       if X_loop_count = 2 then do                   
  253.          send '\w\w'
  254.          send 'zip x.mail.zip *.MSG AREAS' /* E */
  255.          send '\r'
  256.       end
  257.  
  258.       if X_loop_count = 3 then do                   
  259.          send '\w\w'
  260.          send 'rm *.MSG AREAS'             /* F */
  261.          send '\r'
  262.       end
  263.  
  264.    /* get AMIGA netnews */
  265.  
  266.       if X_loop_count = 4 then do                   
  267.          send '\w\w'
  268.          send 'cp x.amiga.newsrc .newsrc'  /* G */
  269.          send '\r'
  270.       end
  271.  
  272.       if X_loop_count = 5 then do                   
  273.          send '\w\w'
  274. /*       send 'uqwk +x +n +L -m -B0 +r'      +r = TEST i.e. no updates    */
  275.          send 'uqwk +x +n +L -m -B0'       /* H */
  276.          send '\r'
  277.       end
  278.  
  279.       if X_loop_count = 6 then do                   
  280.          send '\w\w'
  281.          send 'zip x.amiga.zip *.MSG AREAS' /* I */
  282.          send '\r'
  283.       end
  284.  
  285.       if X_loop_count = 7 then do                   
  286.          send '\w\w'
  287.          send 'cp .newsrc x.amiga.newsrc'  /* J */
  288.          send '\r'
  289.       end
  290.  
  291.       if X_loop_count = 8 then do                   
  292.          send '\w\w'
  293.          send 'rm *.MSG AREAS'             /* K */
  294.          send '\r'
  295.       end
  296.  
  297.    /* get PRIMENET netnews */
  298.  
  299.       if X_loop_count = 9 then do                   
  300.          send '\w\w'
  301.          send 'cp x.pnet.newsrc .newsrc'   /* L */
  302.          send '\r'
  303.       end
  304.  
  305.       if X_loop_count = 10 then do                   
  306.          send '\w\w'
  307. /*       send 'uqwk +x +n +L -m -B0 +r'      +r = TEST i.e. no updates    */
  308.          send 'uqwk +x +n +L -m -B0'       /* M */
  309.          send '\r'
  310.       end
  311.  
  312.       if X_loop_count = 11 then do                   
  313.          send '\w\w'
  314.          send 'zip x.pnet.zip *.MSG AREAS' /* N */
  315.          send '\r'
  316.       end
  317.  
  318.       if X_loop_count = 12 then do                   
  319.          send '\w\w'
  320.          send 'cp .newsrc x.pnet.newsrc'   /* O */
  321.          send '\r'
  322.       end
  323.  
  324.       if X_loop_count = 13 then do                   
  325.          send '\w\w'
  326.          send 'rm *.MSG AREAS'             /* P */
  327.          send '\r'
  328.       end
  329.  
  330.    /* get OTHER netnews */
  331.  
  332.       if X_loop_count = 14 then do                   
  333.          send '\w\w'
  334.          send 'cp x.other.newsrc .newsrc'  /* Q */
  335.          send '\r'
  336.       end
  337.  
  338.       if X_loop_count = 15 then do                   
  339.          send '\w\w'
  340. /*       send 'uqwk +x +n +L -m -B0 +r'      +r = TEST i.e. no updates    */
  341.          send 'uqwk +x +n +L -m -B0'       /* R */
  342.          send '\r'
  343.       end
  344.  
  345.       if X_loop_count = 16 then do                   
  346.          send '\w\w'
  347.          send 'zip x.other.zip *.MSG AREAS' /* S */
  348.          send '\r'
  349.       end
  350.  
  351.       if X_loop_count = 17 then do                   
  352.          send '\w\w'
  353.          send 'cp .newsrc x.other.newsrc'  /* T */
  354.          send '\r'
  355.       end
  356.  
  357.       if X_loop_count = 18 then do                   
  358.          send '\w\w'
  359.          send 'rm *.MSG AREAS'             /* U */
  360.          send '\r'
  361.       end
  362.  
  363.    /* download all x items  */
  364.  
  365.       if X_loop_count = 19 then do
  366.          send '\w\w'
  367.          send 'sz x.*'                     /* V */
  368.          send '\r'
  369.       end
  370.  
  371.    /* kill all *.zip items  */
  372.  
  373.       if X_loop_count = 20 then do
  374.          send '\w\w'
  375.          send 'rm *.zip'                   /* W */
  376.          send '\r'
  377.       end
  378.  
  379. /* below keeps you inside Primenet if SIT_STAY exists
  380.    note: use number one greater than above....        */
  381.    
  382.       if X_loop_count = 21 then do  
  383.          if exists('ram:SIT_STAY')~=0 then do
  384.             waitlost = 'n'
  385.             leave  
  386.          end   
  387.          send '\w\w'
  388.          send 'x'                          /* X */
  389.          send '\r'
  390.          waitlost = 'n'
  391.          leave  
  392.       end
  393.  
  394.       call delay(1) 
  395.  
  396. /* note: below uses the same count number as above */
  397.  
  398.       if X_loop_count > 21 then do
  399.          waitlost = 'y'
  400.          msg '****** AUTO_SOUP - X_loop_count > 21 ******'
  401.          Capture OFF
  402.          leave  
  403.       end
  404.  
  405.    end  /*   comes from "if NRESULT = '][>' then do" way back there   */                       
  406.  
  407.  
  408.    if waitlost ~= ' ' then
  409.       leave
  410.  
  411. end  /*   from WAIT way way back there   */
  412. return
  413.  
  414. CLEANUP:
  415. OPTIONS RESULTS
  416. address command
  417.  
  418. dateYYMMDD=right(date(sorted),6)              
  419.  
  420. timea=translate(time(n),' ',':')              
  421. parse value timea with timeHH timeMM timeSS .  
  422. timeHHMMSS=timeHH||timeMM||timeSS 
  423.  
  424. if exists('RAM:-dl/pnetinet.qwk')~=0 then do
  425.  
  426. /*  
  427.    address command 'rename RAM:-dl/pnetinet.qwk RAM:-dl/pnetinet.qwk.'dateYYMMDD'.'timeHHMM    
  428.  
  429. ************************************************************************
  430.     can anyone tell me why the above line will not work, while the next
  431.     two will, please let me know. I'm stumped!
  432. ************************************************************************
  433. */
  434.    address command 'copy RAM:-dl/pnetinet.qwk RAM:-dl/pnetinet.qwk.'dateYYMMDD'.'timeHHMMSS    
  435.    address command 'delete RAM:-dl/pnetinet.qwk'
  436. end
  437.     
  438. if exists('RAM:-dl/.newsrc')~=0 then do  
  439.    address command 'copy RAM:-dl/.newsrc RAM:-dl/pnetinet.tkn.'dateYYMMDD'.'timeHHMMSS    
  440.    address command 'delete RAM:-dl/.newsrc'    
  441. end
  442.     
  443. if exists('RAM:.newsrc')~=0 then do  
  444.    address command 'copy RAM:.newsrc RAM:UL_newsrc.'dateYYMMDD'.'timeHHMMSS    
  445.    address command 'delete RAM:.newsrc'    
  446. end
  447.  
  448. /* ****************** MAIL STUFF ****************** */    
  449.  
  450. if exists('RAM:-dl/x.mail.zip')~=0 then do  
  451.    address command 'copy RAM:-dl/x.mail.zip RAM:-dl/x.mail.zip.'dateYYMMDD'.'timeHHMMSS    
  452.    address command 'delete RAM:-dl/x.mail.zip'    
  453. end
  454.  
  455. /* ****************** AMIGA STUFF ****************** */    
  456.     
  457. if exists('RAM:-dl/x.amiga.zip')~=0 then do  
  458.    address command 'copy RAM:-dl/x.amiga.zip RAM:-dl/x.amiga.zip.'dateYYMMDD'.'timeHHMMSS    
  459.    address command 'delete RAM:-dl/x.amiga.zip'    
  460. end
  461.     
  462. if exists('RAM:-dl/x.amiga.newsrc')~=0 then do  
  463.    address command 'copy RAM:-dl/x.amiga.newsrc RAM:-dl/x.amiga.newsrc.'dateYYMMDD'.'timeHHMMSS    
  464.    address command 'delete RAM:-dl/x.amiga.newsrc'    
  465. end
  466.  
  467. /* ****************** PRIMENET STUFF ****************** */    
  468.     
  469. if exists('RAM:-dl/x.pnet.zip')~=0 then do  
  470.    address command 'copy RAM:-dl/x.pnet.zip RAM:-dl/x.pnet.zip.'dateYYMMDD'.'timeHHMMSS    
  471.    address command 'delete RAM:-dl/x.pnet.zip'    
  472. end
  473.     
  474. if exists('RAM:-dl/x.pnet.newsrc')~=0 then do  
  475.    address command 'copy RAM:-dl/x.pnet.newsrc RAM:-dl/x.pnet.newsrc.'dateYYMMDD'.'timeHHMMSS    
  476.    address command 'delete RAM:-dl/x.pnet.newsrc'    
  477. end
  478.  
  479. /* ****************** OTHER STUFF ****************** */    
  480.     
  481. if exists('RAM:-dl/x.other.zip')~=0 then do  
  482.    address command 'copy RAM:-dl/x.other.zip RAM:-dl/x.other.zip.'dateYYMMDD'.'timeHHMMSS    
  483.    address command 'delete RAM:-dl/x.other.zip'    
  484. end
  485.     
  486. if exists('RAM:-dl/x.other.newsrc')~=0 then do  
  487.    address command 'copy RAM:-dl/x.other.newsrc RAM:-dl/x.other.newsrc.'dateYYMMDD'.'timeHHMMSS    
  488.    address command 'delete RAM:-dl/x.other.newsrc'    
  489. end
  490.  
  491. /* ****************** END STUFF ****************** */    
  492.     
  493. if exists('RAM:SIT_STAY')~=0 then   
  494.    address command 'delete RAM:SIT_STAY'    
  495.  
  496. return
  497.  
  498.